import time


def gettime(func):
    def inner(*args, **kwargs):
        begin = time.time()
        ret = func(*args, **kwargs)
        end = time.time()
        res = end - begin
        print("函数%s运行时间为 %s" %(func,res))
        return ret
    return inner


@gettime
def func1():
    print("func1 开始运行.....")
    time.sleep(2)
    print("fun1运行结束")

func1()


@gettime
def func2():
    print("func2运行开始。。。。")
    for i in range(5):
        time.sleep(1)
        print("运行中 %s" % i)
    print("func2运行结束")
func2()
